<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>微信扫码登录</title>
</head>
<body>
<div id="qrcode"></div>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript"  src="qrcode.min.js"></script>
<script>
  $(function() {
    // 生成二维码
    var qrcode = new QRCode(document.getElementById("qrcode"), {
      text: "http://192.168.11.101:8006/platform/wechat/login",
      width: 256,
      height: 256,
      colorDark : "#000000",
      colorLight : "#ffffff",
      correctLevel : QRCode.CorrectLevel.H
    });
    // 轮询检查用户是否已经扫码
    setInterval(function() {
      $.get("http://192.168.11.101:8006/platform/wechat/checkScan", function(result) {
        console.log("#####################")
        console.log(result)
        console.log("#####################")
        if (result.code == 0) {
          alert("请先扫码登录");
        } else if (result.code == 1) {
          // 用户已经扫码，跳转到回调页面
          window.location.href = "http://192.168.11.101:8006/platform/wechat/callback?code=" + result.data.code + "&state=" + result.data.state;
        }
      });
    }, 10000);
  });
</script>
</body>
</html>
